import userrequest from "@/request/userrequest";
interface UserForLogIn {
    username:string,
    password:string,
    verifyCode:string,
    captchaId:string
}
interface Role{
    rid:number,
    rname:string,
    remark:string
}
interface User{
    id:number| null,
    username:string,
    password:string,
    type:number |null,
    remarks:string,
    imgPath:string,
    roles:Role[]
}
export const userapi = {
    async logIn(userInfoVO:UserForLogIn) {
        console.log(userInfoVO);
        let res = await userrequest.post("/logIn",userInfoVO);
        return res;
    },
    createCaptch() {
        let res = userrequest.get("/createCaptch");
        return res;
    },
    getAllUsers(currentPage:string, pageSize:string) {
        let res = userrequest.get("/all",{params:{
            currentPage,pageSize
        }})
        return res;
    },
    getUsersByCondition(currentPage:string, pageSize:string,user:User) {
        let res = userrequest.post("/conditions", user, {params:{currentPage,pageSize}});
        return res;
    },
    getAllRoles() {
        let res = userrequest.get("/roles");
        return res;
    },
    modifyUserRoles(roleIds:string,userId:number) {
        let res =  userrequest.put("/modifyroles",null,{params:{roleIds,userId}});
        return res;
    },
    uploadImg(formData:any) {
        let res = userrequest.post("/fileupload",formData);
        return res;
    },
    addUser(user:User) {
        let res = userrequest.post("/insert",user);
        return res;
    }
}